import React from "react";
import KeepAliveCom from 'react-activation'
import {type routeMapType} from "@/typings/router";

type Props = {
    children: React.ReactNode
}
const KeepAlive: React.FC<Props & routeMapType> = (props): React.ReactNode => {

    return (
        <React.Fragment>
            {props.meta?.isKeepAlive ?
                <KeepAliveCom cacheKey={props.path} name={props.path} saveScrollPosition={true}>{props.children}</KeepAliveCom> : <>{props.children}</>}
        </React.Fragment>
    )
}

export default KeepAlive
